ES_YUMREPO_FILE='/etc/yum.repos.d/elasticsearch.repo'
if [ ! -f $ES_YUMREPO_FILE ]; then
	echo "Installing ElasticSearch Keys"
	rpm --import http://packages.elasticsearch.org/GPG-KEY-elasticsearch

	echo "Installing ElasticSearch Repo"
	cp /vagrant/elasticsearch.repo $ES_YUMREPO_FILE
fi

echo "Update CentOS"
yum -u update

if [ ! -f '/etc/init.d/elasticsearch' ]; then
	yum -y install elasticsearch java
	/etc/init.d/elasticsearch start
fi

# Install PIP and ElasticSearch

if [ ! -f '/usr/bin/pip' ]; then
	curl https://bootstrap.pypa.io/get-pip.py | python
	pip install elasticsearch
fi
